var $ = require('../../../utils/helper.js'), that = null
var app = getApp()
Page({
  data: {

  },
  onLoad(e) {
    that = this
    let id = e.id
  
    that.setData({ id: id })
  },
  onReady: function () {
    $.check(that)
  },
  init: function () {
    that.details()
    that.gettableconfig()
  },
  details: function () {
    $.post("api/signup/detail", { user_id: that.data.id }, function (data) {
      that.setData({ info: data })
    })
   
  },
  gettableconfig:function(){
    $.post("api/signup/tableconfig_show", { user_id: that.data.id }, function (data) {
      that.setData({tableconfig:data})
    })
  },
  upload:function(e){
    wx.chooseImage({
      success(res) {
        let tempFilePaths = res.tempFilePaths

        $.upload("signup", tempFilePaths[0], function (data) {
          that.setData({
            photo: data
          })
        })
      }
    })
  },
  make:function(e){
    wx.showLoading({
      title: '正在初始化',
    })
    $.post("api/signup/make", {user_id:that.data.id, info: e.detail.value},function(orderno){
      if(orderno!=null){
        $.pay("api/signup/getpay",{orderno:orderno},function(){
          wx.hideLoading()
          wx.switchTab({
            url: '/pages/setting/index/index',
          })
        },function(){
          wx.hideLoading()
        })
      }else{
        wx.hideLoading()
        wx.switchTab({
          url: '/pages/setting/index/index',
        })
      }
    })
  }
}) 